<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>添加用户</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
</head>
<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/EasyBuy/statics/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" >
	$(document).ready(function() {

				var emaill = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/;
				var phone = /^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/;
				var sfzzz = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;	//身份证正则
							
				
				
				
				
				$("#l_user").blur(function (){
					var user=document.getElementById("l_user");
					if(user.validity.valueMissing==true){
						user.setCustomValidity("用户不能为空");
					}else{
						user.setCustomValidity("");
					}
				});
				$("#pwd1").blur(function (){
					var pwd1=document.getElementById("pwd1");
					if(pwd1.validity.valueMissing==true){
						pwd1.setCustomValidity("密码不能为空");
					}else{
						pwd1.setCustomValidity("");
					}
				});
				$("#pwd2").blur(function (){
					var pwd1=document.getElementById("pwd1");
					var pwd2=document.getElementById("pwd2");
					if(pwd2.validity.valueMissing==true){
						pwd2.setCustomValidity("请再次输入密码");
					}else if(pwd1!=pwd2){
						pwd2.setCustomValidity("俩次密码不一致");
					}else {
						pwd2.setCustomValidity("");
					}
				}); 
				$("#l_email").blur(function (){
					var email=document.getElementById("l_email");
					if(email.validity.valueMissing==true){
						email.setCustomValidity("邮箱不能为空");
					}else if(emaill.test(email)){
						email.setCustomValidity("邮箱格式不正确");
					}else {
						email.setCustomValidity("");
					}
				});
				$("#l_tel").blur(function (){
					var tel=document.getElementById("l_tel");
					if(tel.validity.valueMissing==true){
						tel.setCustomValidity("电话不能为空");
					}else if(phone.test(tel)){
						tel.setCustomValidity("电话格式不正确");
					}else {
						tel.setCustomValidity("");
					}
				});
				$("#l_mem").blur(function (){
					var mem=document.getElementById("l_mem");
					if(mem.validity.valueMissing==true){
						mem.setCustomValidity("身份证号不能为空");
					}else if(sfzzz.test(tel)){
						mem.setCustomValidity("身份证号格式不正确");
					}else {
						mem.setCustomValidity("");
					}
				});
				$("#l_num").blur(function (){
					var name=document.getElementById("l_num");
					if(name.validity.valueMissing==true){
						name.setCustomValidity("真实姓名不能为空");
					}else {
						name.setCustomValidity("");
					}
				});
				
				$("#bto").click(function (){
					var username=$("#l_user").val(); //用户名       
					var pwd= $("#pwd1").val();  //第一次密码
					var email= $("#l_email").val(); //邮箱
					var phone= $("#l_tel").val(); //手机号
					var sfz= $("#l_mem").val();   //身份证
					var zsname=$("#l_num").val();   //真实姓名
					location.href="UserServlet?opr=add&username="+username+"&pwd="+pwd+"&email="+email+"&phone="+
							phone+"&sfz="+sfz+"&zsname="+zsname;
				});
			});
</script>
  <body>
  	<%@ include file="../../common/header.jsp" %>
	<%@ include file="../../common/backendHeader.jsp" %>
  	
  	
  	<c:choose>
		<c:when test="${empty applicationScope.type }">
			<% 	request.getRequestDispatcher("../../UserServlet?opr=type&href=Member_User_Insert&href1=user").forward(request, response); %>
		</c:when>
		<c:otherwise>
			<c:if test="${applicationScope.type==1 }">
  				<%@ include file="../../common/sideMamber.jsp" %> 
			</c:if>
			<c:if test="${applicationScope.type==0 }">
				<%@ include file="../../common/sideUser.jsp" %> 
			</c:if>
		</c:otherwise>
	 </c:choose>
	 
  <div class="m_right">
  <div style="margin-left:25px;margin-top:20px"><font size=4>添加用户</font></div>
   <table border="0" id="admin" class="order_tab" style="width:530px;margin-top:50px; margin-bottom:30px;" cellspacing="0" cellpadding="0">
			<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;用户名
								&nbsp;</td>
							<td><input type="text" name="username"  class="l_user" id="l_user"/>
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;密码
								&nbsp;</td>
							<td><input type="password" name="pwd" class="l_pwd" id="pwd1" />
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;确认密码
								&nbsp;</td>
							<td><input type="password" name="qpwd"  class="l_pwd" id="pwd2" />
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;邮箱
								&nbsp;</td>
							<td><input type="text"  name="email" class="l_email" id="l_email" />
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;手机
								&nbsp;</td>
							<td><input type="text" name="phone"  class="l_tel"  id="l_tel"/>
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;身份证号
								&nbsp;</td>
							<td><input type="text" name="mem" class="l_mem" id="l_mem"/>
							</td>
						</tr>
						<tr height="50">
							<td align="right"><font color="#ff4e00">*</font>&nbsp;真实姓名
								&nbsp;</td>
							<td><input type="text" name="num" class="l_num" id="l_num"/>
							</td>
						</tr>
			<tr style="height:40px">
				<td  colspan="2" style="text-align:center"><input  class="log_btn" style="height:30px;width:200px" id="bto" type="button" value="添&nbsp;&nbsp;&nbsp;&nbsp;加" /></td>
			</tr>
	</table>
  </div>
  <%@ include file="../../common/footer.jsp" %>    <!--引入下边栏-->
  </body>
</html>
